package com.gitee.xhs.window.windowOperator;

import com.gitee.xhs.dao.AggregateTransactionDao;
import com.gitee.xhs.sampleRecod.transactionRecord.Transaction;
import org.apache.flink.api.common.functions.AggregateFunction;

/**
 * @author BigHead
 * @date 2022/7/25 14:31
 * @description DefaultAggregateWindowFunction
 */
public class DefaultAggregateWindowFunction implements AggregateFunction<Transaction, AggregateTransactionDao, AggregateTransactionDao> {
    @Override
    public AggregateTransactionDao createAccumulator() {
        return new AggregateTransactionDao();
    }

    @Override
    public AggregateTransactionDao add(Transaction value, AggregateTransactionDao accumulator) {
        accumulator
                .setTransaction(value);
        return accumulator;
    }

    @Override
    public AggregateTransactionDao getResult(AggregateTransactionDao accumulator) {
        return accumulator;
    }

    @Override
    public AggregateTransactionDao merge(AggregateTransactionDao a, AggregateTransactionDao b) {
        return a.merge(b);
    }
}
